package com.qf.commerce.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.commerce.common.dto.FunctionDto;
import com.qf.commerce.common.vo.AccountVo;
import com.qf.commerce.common.vo.FunctionVo;
import com.qf.commerce.entity.Function;
import com.qf.commerce.mapper.FunctionMapper;
import com.qf.commerce.service.FunctionService;
import com.qf.commerce.utils.CommonBeanUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@Service
public class FunctionServiceImpl implements FunctionService {
    @Resource
    private FunctionMapper functionMapper;

    @Override
    public int insertFunction(FunctionDto functionDto) {
        return functionMapper.insertFunction(functionDto);
    }

    @Override
    public int deleteFunction(List<Long> ids) {
        return functionMapper.deleteFunction(ids);
    }

    @Override
    public int updateFunction(Function function,Long functionId) {
        return functionMapper.updateFunction(function,functionId);
    }

    @Override
    public Function selectFunctionDetail(Long functionId) {
        return functionMapper.selectFunctionDetail(functionId);
    }


    @Override
    public PageInfo<FunctionVo> selectFunction(Integer status, String functionName, String functionCoding,Integer page, Integer size) {
        return CommonBeanUtils.copyPage(PageHelper.startPage(page,size).doSelectPageInfo(() -> functionMapper.selectFunction(status,functionName,functionCoding)),new PageInfo<FunctionVo>(),FunctionVo::new);
    }

    @Override
    public PageInfo<FunctionVo> selectFunctionByTime(String startCreateTime, String endCreateTime, Integer page, Integer size) {
        return CommonBeanUtils.copyPage(PageHelper.startPage(page,size).doSelectPageInfo(() -> functionMapper.selectFunctionByTime(startCreateTime,endCreateTime)),new PageInfo<FunctionVo>(),FunctionVo::new);
    }



}
